<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="./src/animate.min.css">
  <link rel="stylesheet" href="./src/swiper-bundle.min.css">
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    html, body {
      width: 100%;
      height: 100%;
    }

    .banner {
      width: 100%;
      height: 100%;
    }

    .first {
      background-color: orange;
      position: relative;
    }

    .first > p:nth-child(1) {
      width: 100%;
      height: 100%;
    }

    .first > p:nth-child(1) > img {
      width: 100%;
      height: 100%;
      display: block;
    }

    .first > p:nth-child(2) {
      position: absolute;
      left: 50%;
      transform: translateX(-40%);
      top: 50px;
    }

    .first > p:nth-child(3) {
      width: 100%;
      text-align: center;
      font-size: 30px;
      font-weight: 700;
      color: #fff;
      position: absolute;
      top: 300px;
    }

    .first.active > p:nth-child(3) {
      animation: leftDown 1s linear;
    }

    .second {
      background-color: skyblue;
      position: relative;
    }

    .second > p {
      font-size: 20px;
      font-weight: 700;
      color: #fff;
      position: absolute;
      left: 500px;
    }

    .second > p:nth-child(1) {
      top: 30px;
    }
    .second > p:nth-child(2) {
      top: 80px;
    }
    .second > p:nth-child(3) {
      top: 130px;
    }
    .second > p:nth-child(4) {
      top: 180px;
    }
    .second > p:nth-child(5) {
      top: 230px;
    }
    .second > p:nth-child(6) {
      top: 280px;
    }

    .second.active > p:nth-child(1) {
      animation: leftDown 1s linear both;
    }

    .second.active > p:nth-child(2) {
      animation: leftDown 1s .3s linear both;
    }

    .second.active > p:nth-child(3) {
      animation: leftDown 1s .6s linear both;
    }
    .second.active > p:nth-child(4) {
      animation: leftDown 1s .9s linear both;
    }
    .second.active > p:nth-child(5) {
      animation: leftDown 1s 1.2s linear both;
    }
    .second.active > p:nth-child(6) {
      animation: leftDown 1s 1.5s linear both;
    }

    .third {
      background-color: purple;
    }

    /* 设计动画 */
    @keyframes leftDown {
      0% {
        left: 500px;
      }

      40% {
        left: 10px;
      }

      60% {
        left: 50px;
      }

      100% {
        left: 30px;
      }
    }
  </style>
</head>
<body>

  <div class="swiper banner" id="banner">
    <div class="swiper-wrapper">
      <!-- 这里一个 slide 就是一屏的内容 -->
      <!-- 第一页 [0] -->
      <div class="swiper-slide first">
        <p><img src="./imgs/002.gif" alt=""></p>
        <p><img src="./imgs/001.gif" alt=""></p>
        <p class="active">欢迎来到前端2304</p>
      </div>

      <!-- 第二页 [1] -->
      <div class="swiper-slide second">
        <p>姓名 : Gavin</p>
        <p>年龄 : 18</p>
        <p>工作经历 : 10年</p>
        <p>学历 : 统招本科</p>
        <p>电话 : 13312345678</p>
        <p>邮箱 : 12345678@qq.com</p>
      </div>

      <!-- 第三页 [2] -->
      <div class="swiper-slide third">Slide 3
        啊但是发顺丰撒旦法

      </div>
    </div>

    <!-- 如果需要滚动条 -->
    <div class="swiper-scrollbar"></div>
  </div>

  <div class="music">
    <!--
      API
        + 获取 audio 元素
          => 元素.play()   播放
          => 元素.puase()  暂停
    -->
    <audio src="" style="display: none"></audio>
    <i></i>
  </div>

  <script src="./src/swiper-bundle.min.js"></script>
  <script src="./src/swiper.animate1.0.3.min.js"></script>
  <script>
    // 获取元素
    const slides = document.querySelectorAll('.swiper-slide');

    // console.log(slides);
    //获取元素  

    new Swiper('#banner', {
      direction: 'vertical',
      // initialSlide: 1,
      // 滚动条
      scrollbar: {
        el: '.swiper-scrollbar',
      },
      // 绑定事件
      on: {
        // 时机: 每一屏滚动过渡结束的时候触发
        slideChangeTransitionEnd: function () {
          // 能拿到当前是第几页
          // 语法: this.activeIndex, 注意, 拿到的是索引
          const index = this.activeIndex
        //   console.log(index);
            slides.forEach(item => item.classList.remove('active'))
            slides[index].classList.add('active')
        }
      }
    })
  </script>
</body>
</html>
